import request from "@/utils/request";
import type {
  GetTrademarkListResponse,
  TrademarkItem,
  GetAllTrademarkList,
} from "./model/trademarkModel";
// enum ts枚举类型  用于定义常量
// 当前模块的所有请求地址定义在一起（统一定义接口地址）
enum Api {
  getTrademarkList = "/admin/product/baseTrademark",
  getAllTrademarkList = "/admin/product/baseTrademark/getTrademarkList",
  addTrademark = "/admin/product/baseTrademark/save",
  updateTrademark = "/admin/product/baseTrademark/update",
  deleteTrademark = "/admin/product/baseTrademark/remove",
}
/**
 * 获取品牌分页列表
 * @param page 页码
 * @param limit 每页多少条
 * @returns GetTrademarkListResponse
 */
export const getTrademarkListApi = (page: number, limit: number) => {
  return request.get<any, GetTrademarkListResponse>(
    Api.getTrademarkList + `/${page}/${limit}`
  );
};
/**
 * 添加品牌
 * @param tmName 品牌名称
 * @param logoUrl 品牌LOGO
 * @returns null
 */
export const addTrademarkApi = (tmName: string, logoUrl: string) => {
  return request.post<any, null>(Api.addTrademark, { tmName, logoUrl });
};

/**
 * 修改品牌
 * @param data 修改的品牌
 * @returns null
 */
export const updateTrademarkApi = (data: TrademarkItem) => {
  return request.put<any, null>(Api.updateTrademark, data);
};

/**
 * 删除品牌
 * @param id 要删除的品牌id
 * @returns null
 */
export const deleteTrademarkApi = (id: number) => {
  return request.delete<any, null>(Api.deleteTrademark + `/${id}`);
};

export const getAllTrademarkListApi = () => {
  return request.get<any, GetAllTrademarkList>(Api.getAllTrademarkList);
};
